package org.codeart.memento.example01;

import lombok.Data;
import lombok.experimental.Accessors;

/**
 * 发起者
 */
@Data
@Accessors(chain = true)
public class Originator {
    
    private String state = "raw object";
    
    private String id;
    
    private String name;
    
    private String phone;

    public Originator() {
        
    }

    public Originator(String id, String name, String phone) {
        this.id = id;
        this.name = name;
        this.phone = phone;
    }

    public Memento createMemento() {
        return new Memento(id, name, phone);
    }
    
    public void restore(Memento memento) {
        this.state = memento.getState();
        this.id = memento.getId();
        this.name = memento.getName();
        this.phone = memento.getPhone();
    }
}
